A foundation for trait-based metaprogramming
نویسندگان
چکیده
Schärli et al. introduced traits as reusable units of behavior independent of the inheritance hierarchy. Despite their relative simplicity, traits offer a surprisingly rich calculus. Trait calculi typically include operations for resolving conflicts when composing two traits. In the existing work on traits, these operations (method exclusion and aliasing) are shallow, i.e., they have no effect on the body of the other methods in the trait. In this paper, we present a new trait system, based on the Fisher-Reppy trait calculus, that adds deep operations (method hiding and renaming) to support conflict resolution. The proposed operations are deep in the sense that they preserve any existing connections between the affected method and the other methods of the trait. Our system uses Riecke-Stone dictionaries to support these features. In addition, we define a more fine-grained mechanism for tracking trait types than in previous systems. The resulting calculus is more flexible and expressive, and can serve as the foundation for trait-based metaprogramming, an idiom we introduce. This is an extended version of our workshop paper with the complete formal model and additional details for the soundness proof.
منابع مشابه
An algebraic foundation for automatic feature-based program synthesis
Feature-Oriented Software Development provides a multitude of formalisms, methods, languages, and tools for building variable, customizable, and extensible software. Along different lines of research, different notions of a feature have been developed. Although these notions have similar goals, no common basis for evaluation, comparison, and integration exists. We present a feature algebra that...
متن کاملReflective Composition: the Declarative Composition of Roles to Unify Objects, Roles, & Aspects
As bases for object-orientation, both class-based and prototypebased organization have limitations. We argue that roles have significant benefits as a foundation for organizing objects. We further argue that these benefits can be realised most flexibly using logic meta-programming. Additional benefits from this approach are to reduce redundancy and subsume aspects.
متن کاملFunctional Extensions to the Boost Metaprogram Library
Boost metaprogram library is one of the most important foundation for C++ template metaprogramming. The library implements commonly used compilation-time algorithms and meta-datastructures in an extendible and reusable way. Despite the well-known commonality of functional programming paradigm, boost mpl lacks a few important features to directly support functional style. In this paper we propos...
متن کاملMetaprogramming with Traits
In many domains, classes have highly regular internal structure. For example, so-called business objects often contain boilerplate code for mapping database fields to class members. The boilerplate code must be repeated per-field for every class, because existing mechanisms for constructing classes do not provide a way to capture and reuse such member-level structure. As a result, programmers o...
متن کاملRun-time Manipulation of Programs in a Statically-Typed Language
This article is an extended abstract of a doctoral dissertation on metaprogramming and programming language design. A metaprogramming model is studied and implemented in a statically–typed pure object– oriented programming language Zero. The object model of language is based on closures which enables metaprogramming model to achieve a high degree of dynamic manipulation, normally only found in ...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2005